<template>
  <div style="display: inline-block">
    <slot v-if="hasPermission()"></slot>
  </div>
</template>

<script>
import {
  getBtnPermission,
  initBtnPermission,
} from "@/components/business/global-filter";
import { isNotNull } from "@/util/common-util";

export default {
  name: "auth-wrapper",
  props: {
    btnKey: {
      type: String,
      default: "",
    },
  },
  data() {
    return {};
  },
  created() {
    initBtnPermission(JSON.parse(localStorage.getItem("permission:buttons")));
  },
  methods: {
    hasPermission() {
      console.log(getBtnPermission());
      return isNotNull(getBtnPermission()[this.btnKey]);
    },
  },
};
</script>

<style scoped></style>
